package cn.yuemouren.leetcode;


/**
 * @Author: Timi
 * @Description: 125. 验证回文串
 * @Date: 2020/7/27 8:39
 */
public class Test_125 {

    public boolean isPalindrome(String s) {
        if(s.isEmpty())
            return true;
        StringBuilder builder = new StringBuilder();
        //字母全部转小写
        String param = s.toLowerCase();
        char[] chars = param.toCharArray();
        //只保留字母和数字
        for (char c : chars){
            if((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')){
                builder.append(c);
            }
        }
        return builder.toString().equals(builder.reverse().toString());
    }
}
